home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C - WorkDisk II.adf / hop1.c next >
C/C++ Source or Header  |  1987-01-02  |  3KB  |  172 lines

  1. #include "exec/types.h"
  2. #include "intuition/intuition.h"
  3. #include "math.h"
  4.  
  5. struct IntuitionBase *IntuitionBase;
  6. struct Window *NoBorder;
  7. struct GfxBase *GfxBase;
  8. struct RastPort *r;
  9. struct Screen *Scrn;
  10.  
  11. #define INTUITION_REV 29
  12. #define GRAPHICS_REV 29
  13.  
  14. main()
  15. {
  16.  ULONG flags;
  17.  SHORT x,y,w,h,d,c0,c1;
  18.  USHORT mode;
  19.  VOID delayfunc(),OpenALL();
  20.  int i,num;
  21.  float aa,uu,vv,a,b,c;
  22.  register float u, v;
  23.  double sqrt(),fabs();
  24.  
  25.  OpenALL();
  26.  
  27.  /* ======Open een hires custom screen====== */
  28.  
  29.  y=0;
  30.  w=640;
  31.  h=400;
  32.  d=4;
  33.  c0=0x07;
  34.  c1=0x09;
  35.  mode=HIRES;
  36.  
  37.  Scrn=(struct Screen *)
  38.          make_screen(y,w,h,d,c0,c1,mode,NULL);
  39.  
  40.  /* ======open een borderless window ====== */
  41.  
  42.  x=y=0;
  43.  w=640;
  44.  h=200;
  45.  flags = ACTIVATE|SMART_REFRESH|BORDERLESS;
  46.  NoBorder=(struct Window *)
  47.              make_window(x,y,w,h,NULL,flags,Scrn,c0,c1);
  48.  
  49.  /* ======teken muurpapier====== */
  50.  
  51.  r=NoBorder->RPort;
  52.  num = 50000;
  53.  a =-3.141592;
  54.  b =0.4;
  55.  c =0.4;
  56.  u=v=uu=vv=0.0;
  57.  for(i=0;i <= num;i=num)
  58.  {
  59.   tekenpixel(3,r,((int)u*30)+320,((int)v*15)+120);
  60.   uu = v - (u<0?1:-1)*sqrt((double)(fabs((double)b*v-c)));
  61.   vv = a - v;
  62.   u = uu;
  63.   v = vv;
  64.  };
  65.  
  66.  /* ======Tijds-pauze====== */
  67.  
  68.  delayfunc(100);
  69.  
  70.  /* ======Close de windows in volgorde====== */
  71.  
  72.  CloseWindow(NoBorder);
  73.  
  74.  delayfunc(10);
  75.  
  76.  CloseScreen(Scrn);
  77.  
  78. }
  79.  
  80. VOID OpenALL()
  81. {
  82.  /*==Intuition==*/
  83.  
  84.  IntuitionBase=(struct IntuitionBase *)
  85.             OpenLibrary("intuition.library",INTUITION_REV);
  86.  
  87.  if(IntuitionBase==NULL)
  88.     exit(FALSE);
  89.  
  90.  /*==Graphics Library==*/
  91.  
  92.  GfxBase=(struct GfxBase *)
  93.           OpenLibrary("graphics.library",GRAPHICS_REV);
  94.  
  95.  if(GfxBase==NULL)
  96.     exit(FALSE);
  97. }
  98.  
  99. make_window(x,y,w,h,name,flags,screen,color0,color1)
  100. SHORT x,y,w,h;
  101. UBYTE *name,color0,color1;
  102. ULONG flags;
  103. struct Screen *screen;
  104.  
  105. {
  106.  struct NewWindow NewWindow;
  107.  
  108.  NewWindow.LeftEdge = x;
  109.  NewWindow.TopEdge = y;
  110.  NewWindow.Width = w;
  111.  NewWindow.Height = h;
  112.  NewWindow.DetailPen = color0;
  113.  NewWindow.BlockPen = color1;
  114.  NewWindow.Title = name;
  115.  NewWindow.Flags = flags;
  116.  NewWindow.IDCMPFlags = NULL;
  117.  NewWindow.Type = CUSTOMSCREEN;
  118.  NewWindow.FirstGadget = NULL;
  119.  NewWindow.CheckMark = NULL;
  120.  NewWindow.Screen = screen;
  121.  NewWindow.BitMap = NULL;
  122.  NewWindow.MinWidth = 0;
  123.  NewWindow.MinHeight = 0;
  124.  NewWindow.MaxWidth = 0;
  125.  NewWindow.MaxHeight = 0;
  126.  
  127.  return(OpenWindow(&NewWindow));
  128.  
  129. }
  130.  
  131. VOID delayfunc(factor)
  132. int factor;
  133. {
  134.  int loop;
  135.  for(loop=0;loop < factor*1000;loop++)
  136.    ;
  137.  return;
  138. }
  139.  
  140. make_screen(y,w,h,d,color0,color1,mode,name)
  141. SHORT y,w,h,d;
  142. UBYTE color0,color1,*name;
  143. USHORT mode;
  144. {
  145.  struct NewScreen NewScreen;
  146.  
  147.  NewScreen.LeftEdge = 0;
  148.  NewScreen.TopEdge = y;
  149.  NewScreen.Width = w;
  150.  NewScreen.Height = h;
  151.  NewScreen.Depth = d;
  152.  NewScreen.DetailPen = color0;
  153.  NewScreen.BlockPen = color1;
  154.  NewScreen.ViewModes = mode;
  155.  NewScreen.Type = CUSTOMSCREEN;
  156.  NewScreen.Font = NULL;
  157.  NewScreen.DefaultTitle = name;
  158.  NewScreen.Gadgets = NULL;
  159.  NewScreen.CustomBitMap = NULL;
  160.  
  161.  return(OpenScreen(&NewScreen));
  162. }
  163.  
  164. tekenpixel(col,rast,s,t)
  165. int col,s,t;
  166. struct RastPort *rast;
  167. {
  168.  SetAPen(rast,col);
  169.  WritePixel(rast,s,t);
  170. }
  171.  
  172.